package shape2D;     // 改包名时可能导致乱码

import javafx.application.Application;
import javafx.scene.Scene;
import javafx.scene.canvas.Canvas;
import javafx.scene.canvas.GraphicsContext;
import javafx.stage.Stage;
import javafx.scene.layout.*;
import javafx.scene.paint.Color;

// 画布
public class CanvasDemo extends Application { 
	private Pane root = new Pane();
	private Canvas canvas;
	
	public static void main(String[] args) {
		launch(args);
	}
	
	@Override
	public void start(Stage stage) {
		
		canvas = new Canvas(500, 400);
		GraphicsContext gc = canvas.getGraphicsContext2D();		// 画笔
		
		gc.setFill(Color.ORANGE);
		gc.fillRect(50, 50, 100, 100);
		
		gc.setFill(Color.RED);
		gc.fillText("hello", 300, 50);
		root.getChildren().add(canvas);
		
		Scene scene = new Scene(root, 500, 400);
		stage.setScene(scene);
		stage.show();
	}
}





